home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PASWIZ14.ZIP / SOURCE.ZIP / MOUSE.PAS < prev    next >
Pascal/Delphi Source File  |  1993-02-28  |  4KB  |  148 lines

  1. {   +----------------------------------------------------------------------+
  2.     |                                                                      |
  3.     |        PasWiz  Copyright (c) 1990-1993  Thomas G. Hanlin III         |
  4.     |             3544 E. Southern Ave. #104,  Mesa, AZ 85204              |
  5.     |                                                                      |
  6.     |                     The Pascal Wizard's Library                      |
  7.     |                                                                      |
  8.     +----------------------------------------------------------------------+
  9.  
  10.  
  11.  
  12. Mouse:
  13.  
  14.    This unit provides mouse support by direct access to the Microsoft mouse
  15.    driver.  It will also work with compatible drivers, such as those produced
  16.    by Logitech and many other companies.  Trackballs and other devices that
  17.    use compatible drivers are likewise fine.
  18.  
  19.    Note that PS/2 computers have rather unusual mouse support, due to an
  20.    incomprehensible decision by IBM.  To the best of my knowledge, these
  21.    routines will not work at all with PS/2 rodents.
  22.  
  23. }
  24.  
  25.  
  26.  
  27. UNIT Mouse;
  28.  
  29.  
  30.  
  31. INTERFACE
  32.  
  33.  
  34.  
  35. FUNCTION Init: Integer;
  36. FUNCTION LeftButton: Boolean;
  37. FUNCTION MidButton: Boolean;
  38. FUNCTION RightButton: Boolean;
  39. FUNCTION WhereX: Integer;
  40. FUNCTION WhereY: Integer;
  41.  
  42. PROCEDURE GotoXY (X, Y: Integer);
  43. PROCEDURE HideCursor;
  44. PROCEDURE Info (VAR Version: Real; VAR Connector, IRQ: Byte);
  45. PROCEDURE LeftClick (VAR Count, X, Y: Integer);
  46. PROCEDURE LeftRelease (VAR Count, X, Y: Integer);
  47. PROCEDURE MidClick (VAR Count, X, Y: Integer);
  48. PROCEDURE MidRelease (VAR Count, X, Y: Integer);
  49. PROCEDURE RightClick (VAR Count, X, Y: Integer);
  50. PROCEDURE RightRelease (VAR Count, X, Y: Integer);
  51. PROCEDURE ShowCursor;
  52. PROCEDURE Window (X1, Y1, X2, Y2: Integer);
  53.  
  54.  
  55.  
  56. { --------------------------------------------------------------------------- }
  57.  
  58.  
  59.  
  60. IMPLEMENTATION
  61.  
  62.  
  63.  
  64. USES
  65.    Dos;
  66.  
  67.  
  68.  
  69. VAR
  70.    Reg: Registers;
  71.  
  72.  
  73.  
  74. { ---- procs to access the mouse driver ----------------------------------- }
  75.  
  76.  
  77.  
  78.  
  79. { range to which to restrict the mouse cursor }
  80. PROCEDURE Window (X1, Y1, X2, Y2: Integer);
  81. BEGIN
  82.    Reg.AX := 7;
  83.    Reg.CX := Y1;
  84.    Reg.DX := Y2;
  85.    Intr($33, Reg);
  86.    Reg.AX := 8;
  87.    Reg.CX := X1;
  88.    Reg.DX := X2;
  89.    Intr($33, Reg);
  90. END;
  91.  
  92.  
  93.  
  94. { basic mouse hardware/software info }
  95. PROCEDURE Info (VAR Version: Real; VAR Connector, IRQ: Byte);
  96. BEGIN
  97.    Reg.AX := 36;
  98.    Intr($33, Reg);
  99.    Version := (Hi(Reg.BX) DIV 16) * 10 + (Hi(Reg.BX) MOD 16)
  100.            + ((Lo(Reg.BX) DIV 16) * 10 + (Lo(Reg.BX) MOD 16)) / 100;
  101.    Connector :=  Hi(Reg.CX);
  102.    IRQ := Lo(Reg.CX);
  103.    { attempt to safeguard against incompatible or outdated drivers }
  104.    IF (Connector < 1) OR (Connector > 20) OR (IRQ = 1) OR (IRQ > 15) THEN BEGIN
  105.       Version := 0.0;
  106.       Connector := 0;
  107.       IRQ := 0;
  108.    END;
  109. END;
  110.  
  111.  
  112.  
  113. {$F+}
  114.  
  115. { the below routines are in assembly language }
  116.  
  117.  
  118.  
  119. FUNCTION Init; external;               { init mouse driver, return buttons }
  120. PROCEDURE HideCursor; external;        { hide mouse cursor }
  121. FUNCTION LeftButton; external;         { return left button status }
  122. FUNCTION MidButton; external;          { return middle button status }
  123. FUNCTION RightButton; external;        { return right button status }
  124. PROCEDURE ShowCursor; external;        { show mouse cursor }
  125. FUNCTION WhereX; external;             { return X coordinate of mouse }
  126. FUNCTION WhereY; external;             { return Y coordinate of mouse }
  127.  
  128. PROCEDURE GotoXY (X, Y: Integer); external;      { set mouse cursor position }
  129.  
  130. { get # of presses of a button & cursor location at last press }
  131. PROCEDURE LeftClick (VAR Count, X, Y: Integer); external;
  132. PROCEDURE MidClick (VAR Count, X, Y: Integer); external;
  133. PROCEDURE RightClick (VAR Count, X, Y: Integer); external;
  134.  
  135. { get # of releases of a button & cursor location at last release }
  136. PROCEDURE LeftRelease (VAR Count, X, Y: Integer); external;
  137. PROCEDURE MidRelease (VAR Count, X, Y: Integer); external;
  138. PROCEDURE RightRelease (VAR Count, X, Y: Integer); external;
  139.  
  140.  
  141. {$L MOUSES}
  142.  
  143.  
  144.  
  145. { ----------------------- initialization code --------------------------- }
  146. BEGIN
  147. END.
  148.